package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.entity.SparePart;
import com.dc.entity.ro.SparePartRO;
import com.dc.service.SparePartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "备件管理")
@RestController
@RequestMapping("/sparePart")
public class SparePartController {

    @Resource
    private SparePartService sparePartService;


    @Log(title = "备件管理", businessDesc = "增加")
    @ApiOperation(value = "增加", notes = "增加")
    @PostMapping("/insertSparePart")
    public ResponseResultVO insertSparePart(@RequestBody SparePartRO ro) {
        return sparePartService.insertSparePart(ro);
    }


    @Log(title = "备件管理", businessDesc = "修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/updateSparePart")
    public ResponseResultVO updateSparePart(@RequestBody SparePartRO ro) {
        return sparePartService.updateSparePart(ro);
    }


    @Log(title = "备件管理", businessDesc = "删除")
    @ApiOperation(value = "删除", notes = "删除")
    @GetMapping("/deleteSparePart")
    public ResponseResultVO deleteSparePart(@RequestParam String id) {
        return sparePartService.deleteSparePart(id);
    }

    @ApiOperation(value = "备件下拉列表", notes = "备件下拉列表")
    @GetMapping("/selectSparePartList")
    public ResponseResultVO selectSparePartList(@RequestParam(required = false) String name) {
        return sparePartService.selectSparePartList(name);
    }

    @ApiOperation(value = "分页查询列表", notes = "查询列表")
    @PostMapping("/selectSparePartListByPage")
    public ResponseResultVO<SparePart> selectSparePartListByPage(@RequestBody SparePartRO ro) {
        return sparePartService.selectSparePartListByPage(ro);
    }
}
